<template>
  <div>
    <TitleBack :title-name="value"/>

<!--    <van-field v-model="personData.loginName" label="用户名"/>-->
    <van-field v-model="personData.userName" label="昵称"/>
    <van-radio-group v-model="personData.sex" direction="horizontal" tag="div" class="sex">
      <van-radio name="0">男</van-radio>
      <van-radio name="1">女</van-radio>
    </van-radio-group>
    <van-field v-model="personData.email" label="E-mail"/>
    <van-field v-model="personData.phonenumber" label="手机号码"/>
    <van-field v-model="personData.remark" label="简介"/>
    <!--    <van-cell title="出生日期" :value="date" @click="show = true"/>-->
    <!--    <van-calendar v-model="show" @confirm="onConfirm"/>-->

    <div style="margin: 16px;">
      <van-button round block type="danger" native-type="submit" @click="click">
        修改
      </van-button>
    </div>
  </div>
</template>

<script>
import TitleBack from "@/components/TitleBack";
import {getPersonalInformation, postEditData} from "@/api/login-aip";

export default {
  name: "EditData",
  data() {
    return {
      value: "修改个人信息",
      personData: '',
      // userName: '',
      // sex: '',
      // date: '',
      // show: false,
    }
  },
  components: {
    TitleBack
  },
  created() {
    getPersonalInformation().then(res => {
      this.personData = res.data
      console.log(res.data)
    })

  },
  methods: {
    // //  日历
    // formatDate(date) {
    //   return `${date.getMonth() + 1}/${date.getDate()}`;
    // },
    // onConfirm(date) {
    //   this.show = false;
    //   this.date = this.formatDate(date);
    //   console.log(this.date)
    // },
    click(){
      console.log(this.personData)
      postEditData(this.personData.userName,this.personData.email,this.personData.phonenumber,this.personData.sex,this.personData.remark).then(res=>{
        console.log(res)
        this.$router.go(-1)
      })
    }
  }
}

</script>

<style scoped lang="less">
.sex {
  margin: 10px 0px 10px 20px;
}
</style>